﻿$(document).ready(function () {
    //remove the left and right bars, show full main panel
    $("#content #contentContainer #mainPanel").addClass("full");
    $("#content #contentContainer").addClass("full");
    $("#content #contentContainer #leftPanel").hide();
    $("#content #contentContainer #rightPanel").hide();

    //hide the menu and sub-menu
    $("#content ul#mainMenu,#content ul#subMenu,#footer").css("visibility", "hidden");
    //--------------------------------------------------------

    $(".btnApproveAlbumSection").click(function () {
        var item = $(this).parents(".buttonsContainer li");

        if (!item.hasClass("disabled")) {
            var mainDialog = updateDialog("אישור מקטע", "190", "400");

            //Invoke AJAX method to show all Approval Checkes
            $.post(pathPrefix + "Albums/ShowApprovalChecks", { "isSection": true }, function (result) {
                mainDialog.html(result);
            }, "html");
        }

        return false;
    });

    $("#btnApproveAllChecks").live("click", function () {
        //check that all Approval checkboxes are selected
        if ($(".approvalCheckbox").length == $(".approvalCheckbox:checked").length) {
            var data = {
                "id": $("#AlbumSectionId").val(),
                "statusId": 2
            };

            var mainDialog = updateDialog("אישור מקטע", "190", "400");

            //Invoke AJAX method to change the album's section status
            $.post(pathPrefix + "Albums/ChangeAlbumSectionStatus", data, function (result) {
                mainDialog.html(result.Value);

                window.setTimeout(function () {
                    //refresh the page
                    window.location = window.location;
                }, 2000);
            }, "json");
        }
    });
});